document.addEventListener("plusready", function () {
  var webview = plus.webview.currentWebview();
  plus.key.addEventListener("backbutton", function () {
    webview.canBack(function (e) {
      if (e.canBack) {
        webview.back();
      } else {
        var first = null;
        plus.key.addEventListener(
          "backbutton",
          function () {
            if (!first) {
              first = new Date().getTime();
              console.log("再按一次退出应用");
              setTimeout(function () {
                first = null;
              }, 1000);
            } else {
              if (new Date().getTime() - first < 1500) {
                plus.runtime.quit();
              }
            }
          },
          false
        );
      }
    });
  });
});
